package com.example.shaidemo;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import androidx.annotation.NonNull;

public class ChaHangyeAdapter  extends ArrayAdapter{
    private static final String TAG = "ChaHangyeAdapter";


    public ChaHangyeAdapter(@NonNull Context context, int resource, @NonNull List<ChaHangye> list) {
        super(context, resource, list);
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        View itemView=convertView;
        if(itemView==null){
            itemView= LayoutInflater.from(getContext()).inflate(R.layout.list_item_cha_hangye,parent,
                    false);
        }
        ChaHangye item=(ChaHangye) getItem(position);
        TextView hangye=(TextView)itemView.findViewById(R.id.cha_hangye_hangye);
        Log.i(TAG, "adapter:hangye=" + hangye);
        TextView redu=(TextView)itemView.findViewById(R.id.cha_hangye_redu_value);
        Log.i(TAG, "adapter:redu=" + redu);
    
        TextView salary=(TextView)itemView.findViewById(R.id.cha_hangye_xinzi);
        Log.i(TAG, "adapter:salary=" + salary);

        TextView gongxian=(TextView)itemView.findViewById(R.id.cha_hangye_gongxian_value);




        //显示

        hangye.setText(item.getHangye());
        redu.setText(item.getRedu());
        salary.setText(item.getSalary());
        salary.setText("￥"+item.getSalary());

        gongxian.setText(item.getGongxian()+"名用户贡献数据");

        return itemView;
    }
}
